﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Dynamic.Core;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Domain.Repositories;

namespace WMS.RBAC.Users
{
	public class UserAppService : IUserAppService
	{
		private readonly IRepository<Permission, int> _permissionRepository;
		private readonly IRepository<Role, int> _roleRepository;
		private readonly IRepository<RolePermission, int> _rolePermissionRepository;
		private readonly IRepository<User, int> _userRepository;
		private readonly IRepository<UserRole, int> _userRoleRepository;

		public UserAppService(IRepository<Permission, int> permissionRepository, IRepository<Role, int> roleRepository, IRepository<RolePermission, int> rolePermissionRepository, IRepository<User, int> userRepository, IRepository<UserRole, int> userRoleRepository)
		{
			_permissionRepository = permissionRepository;
			_roleRepository = roleRepository;
			_rolePermissionRepository = rolePermissionRepository;
			_userRepository = userRepository;
			_userRoleRepository = userRoleRepository;
		}

		public Task<User> Login()
		{
			return null;
		}

		public async Task<PagedResult> UserList(int page, int limit)
		{
			var userList = await _userRepository.GetListAsync();
			PagedResult pageResult = new PagedResult();
			pageResult.RowCount = userList.Count();
			pageResult.Queryable = userList.Skip((page - 1) * limit).Take(limit).AsQueryable();
			return pageResult;
		}

		public async Task<int> AddUser(User userModel)
		{
			await _userRepository.InsertAsync(userModel);
			return 1;
		}

		public Task<int> RemoveUser()
		{
			return null;
		}

		public Task<int> UpdateUser()
		{
			return null;
		}

		public Task<int> AddUser()
		{
			throw new NotImplementedException();
		}
	}
}
